home *** CD-ROM | disk | FTP | other *** search
- /*
- File: PolyClip.h
-
- Contains: The polygon clipper! Performs intersection, union, difference.
-
- Written by: Jens Alfke (based on algorithm by A. C. Kilgour)
-
- Copyright: © 1994 by Apple Computer, Inc., all rights reserved.
-
- Change History (most recent first):
-
- <3> 10/24/94 jpa Added PolyOutset. [1186719]
- <2> 9/9/94 jpa Added kShapeOutset (not yet implemented...)
- [1178690]
- <1> 6/15/94 jpa first checked in
- ---------------------------Moved to ODSOM project.
- <1> 5/9/94 jpa first checked in
-
- Theory Of Operation:
- PolyClip( ) performs Boolean operations on any number of polygons.
- Pass the number of polygons, an array of pointers to them, and the
- operation you want performed:
- kShapeIntersection computes the intersection of all the polygons.
- kShapeUnion computes the union of all the polygons.
- kShapeDifference subtracts all the other polygons from the first.
-
- PolySimplify( ) "simplifies" an input polygon by removing all
- overlaps or self-intersections. F'rinstance, given a pentagram it
- would return a five-pointed star. (This actually just calls
- PolyClip with nPolys=1 and op=kShapeUnion.)
-
- PolyOutset( ) outsets the vertices of a polygon by a given distance,
- or insets them if the distance is negative. The result may need
- simplification, since parts of contours may flip over. The function
- returns True if additional simplification may be needed.
-
- ** PolyClip is _not_ guaranteed to operate properly on self-
- intersecting input polygons for operations other than union.
- If this is a problem, just simplify the inputs beforehand.
-
- ** PolyClip uses winding-rule containment. This means that input
- vertices must be ordered such that positive contours go clockwise
- and holes go counterclockwise, as viewed in a coordinate system
- where the positive Y axis extends downward (i.e. in the Macintosh
- coordinate system, but not that of PostScript or traditional
- computer graphics.)
- */
-
-
- #ifndef _POLYCLIP_
- #define _POLYCLIP_
-
- #ifndef _ODTYPES_
- #include "ODTypes.h"
- #endif
-
-
- typedef enum {
- kShapeIntersection,
- kShapeUnion,
- kShapeDifference,
-
- // For use internally by ODShape: do not pass to PolyClip:
- kShapeOutset,
- kShapeNoOp = -1
- } ODShapeOp;
-
-
- void PolyClip( ODSLong nPolys, const ODPolygon* polys[], ODShapeOp op, ODPolygon &result );
- void PolySimplify( ODPolygon &dstPoly, const ODPolygon &srcPoly );
- // It's okay to use the same ODPolygon for input and output.
-
- ODBoolean PolyOutset( ODPolygon &poly, ODCoordinate distance ); // True if needs simplifying
-
- #endif /*_POLYCLIP_*/
-